package com.app.oasystem.dto;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 分页辅助类
 *
 * @author zbb
 * @date 2021/05/14
 */
@Data
public class PageGridDto {

    private static final int DEFAULT_PAGE_SIZE = 10;

    private Map<String, Object> searchCondition = new HashMap<String, Object>();
    private int startRowNum;
    private int page;
    private int limit;
    private int userId;

    public void init() {
        if (page <= 0) {
            page = 1;
        }
        if (limit <= 0) {
            limit = DEFAULT_PAGE_SIZE;
        }
        this.startRowNum = limit * (page - 1);
    }

    public Map<String, Object> getSearchCondition() {
        return searchCondition;
    }

    public void setSearchCondition(Map<String, Object> searchCondition) {
        this.searchCondition = searchCondition;
    }

    public int getStartRowNum() {
        init();
        return startRowNum;
    }

    public void setStartRowNum(int startRowNum) {
        this.startRowNum = startRowNum;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getlimit() {
        return limit;
    }

    public void setlimit(int limit) {
        this.limit = limit;
    }

}
